import storageUtil from '@/utils/StorageUtil'

// local storage Key常量
export const PageVersionKey = 'ps_TmptAppVersion-page-version-key'
export const ConditionShowListCkedKey = 'ps_TmptAppVersion-condition-column-show-cked-list-key'
export const ColumnShowListCkedKey = 'ps_TmptAppVersion-list-column-show-cked-list-key'
export const isDropMenuKey = 'ps_TmptAppVersion-list-column-show-isdropmenu-key'
export const ColumnShowListWidthKey = 'ps_TmptAppVersion-list-column-width-key'
export const IsExpandedRowCkedKey = 'ps_TmptAppVersion-list-isexpanded-row-key'


// 查询条件 type: input/date/date-range/num-range/select/tree/
export const conditionOptions = [
  { property: 'id', label: 'ID', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'type', label: 'type', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'lowestCode', label: 'lowestCode', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'lowestVersion', label: 'lowestVersion', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'newestCode', label: 'newestCode', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'newestVersion', label: 'newestVersion', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'title', label: 'title', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'content', label: 'content', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'directUrl', label: 'directUrl', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'deleteflag', label: '删除标志', width: 200, show: true, type: 'select', dataResource: 1 },
  { property: 'createdate', label: '创建日期', width: 200, show: true, type: 'date-range', dataResource: 0 },
  { property: 'createman', label: '创建人', width: 200, show: true, type: 'input', dataResource: 0 },
  { property: 'createmanId', label: '创建人ID', width: 200, show: true, type: 'input', dataResource: 0 }
]
// 所有列对象
export const theadOptions = [
      { property: 'id', label: 'ID', width: storageUtil.getColumnWidthFromStorage('id', 150, ColumnShowListWidthKey), show: true, edit: false, sort: 'custom', fixed: false} ,
      { property: 'type', label: 'type', width: storageUtil.getColumnWidthFromStorage('type', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'lowestCode', label: 'lowestCode', width: storageUtil.getColumnWidthFromStorage('lowestCode', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'lowestVersion', label: 'lowestVersion', width: storageUtil.getColumnWidthFromStorage('lowestVersion', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'newestCode', label: 'newestCode', width: storageUtil.getColumnWidthFromStorage('newestCode', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'newestVersion', label: 'newestVersion', width: storageUtil.getColumnWidthFromStorage('newestVersion', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'title', label: 'title', width: storageUtil.getColumnWidthFromStorage('title', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'content', label: 'content', width: storageUtil.getColumnWidthFromStorage('content', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'directUrl', label: 'directUrl', width: storageUtil.getColumnWidthFromStorage('directUrl', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      // 枚举对象， json结构，如: {'id':1, 'name':'无效'}
      { property: 'deleteflag.name', label: '删除标志', width: storageUtil.getColumnWidthFromStorage('deleteflag.name', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false, dataResource: 1} ,
      { property: 'createdate', label: '创建日期', width: storageUtil.getColumnWidthFromStorage('createdate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'createman', label: '创建人', width: storageUtil.getColumnWidthFromStorage('createman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'modifydate', label: '修改日期', width: storageUtil.getColumnWidthFromStorage('modifydate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'modifyman', label: '修改人', width: storageUtil.getColumnWidthFromStorage('modifyman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
]

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

export const pickerOptionsSingleDate = {
  disabledDate(time) {
    return time.getTime() > Date.now()
  },
  shortcuts: [{
    text: '今天',
    onClick(picker) {
      picker.$emit('pick', new Date())
    }
  }, {
    text: '昨天',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      picker.$emit('pick', date)
    }
  }, {
    text: '一周前',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', date)
    }
  }]
}
